package homeworks.day02;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 将当前目录下的所有文件都复制一份，复制的文件命名为:原
 * 文件名_cp.后缀
 * 比如原文件为:test.dat
 * 复制后的文件为:test_cp.dat
 *
 *
 * @author Xiloer
 *
 */
public class Test02 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis1=new FileInputStream("./demo.dat");
        FileOutputStream fos1=new FileOutputStream("./demo_cp.dat");
        int a;
        while ((a=fis1.read())!=-1){
            fos1.write(a);
        }
        fos1.close();
        fis1.close();


        FileInputStream fis2=new FileInputStream("./fos.dat");
        FileOutputStream fos2=new FileOutputStream("./fos_cp.dat");
        int c;
        while ((c=fis2.read())!=-1){
            fos2.write(c);
        }
        fos2.close();
        fis2.close();

    }
}
